﻿// ## 2023/09/04 # 123 # 可以收义兄弟，妻子为宗室 ##
// ## 2023/09/01 # 123 # 菜单指向修改 ##
// ## 2023/08/14 # 123 # 汉室宗亲被收为义子时将失去宗籍 ##
// ## 2023/08/14 # 123 # 君主无子时，收养野心义子概率被突击 ##
// ## 2023/08/14 # 123 # 宗室要求提高至王 ##
// ## 2023/07/13 # 123 # 君主亲子大于5时不能收义子，义子大于5时不能收义子 ##
// ## 2023/07/13 # 123 # 君主为汉室大宗时不能收养子和宗室 ##
// ## 2023/04/09 # 123 # 可以收义子为宗室 ##
// ## 2023/04/09 # 123 # 假名臣子被赐姓时随机名字 ##
// ## 2023/04/09 # 123 # 假姓君主为臣子赐姓时恢复为君主原姓氏 ##
// ## 2023/04/08 # 123 # 可以收养从子为子，兼容唐朝剧本可以收孙以及后代为子 ##
// ## 2022/09/03 # 广汉郑子瑾 # 收为宗室 ##
// ## 2022/08/21 # 123 # 为了剧本设定方便，养子义子区分，赐名系统，回收军师 ##
// ## 2020/12/11 # 白马叔叔 # 赐姓功能、称谓优化 ##
// ## 2020/09/21 # 江东新风 # ch::add_tp替换 ##
// ##2020/09/16 # 江东新风 # 使用条件对君主行动状态进行判定 ##
// ## 2020/08/08 # 氕氘氚 ##
/*
@제작자: HoneyBee
@설명: 특정 무장을 군주의 양자/양녀로 삼을 수 있는 SCRIPT


※ 양자/양녀로 삼을 수 있는 무장의 조건
- <군주>보다 나이가 어린 무장
- 혈연관계가 아닌 무장
- 의형제가 아닌 무장
- 부부가 아닌 무장
- 혐오관계가 아닌 무장


*/

namespace 양자
{


	// ================ CUSTOMIZE ================

	const int ACTION_COST = 50;     	// (행동력 필요량: 기본 50 설정)	
	const int TP_COST = 100;    	   	// (기교P 필요량: 기본 100 설정)

	bool 혈연_설정 = true;    	   			// (군주의 혈연으로 설정할지 여부, true(on), false(off))
	bool 세대_설정 = true;    	   			// (군주의 2세로 설정할지 여부, true(on), false(off))

	const int KEY = pk::hash("泉大");
	/*
	特殊君主：
	武将_花鬘 = 94;
	武将_祝融 = 248;
	const int 武将_带来洞主 = 390;
	const int 武将_大乔 = 387;
	const int 武将_小乔 = 266;
	const int 武将_貂蝉 = 424;
	const int 武将_朶思大王 = 392;
	const int 武将_木鹿大王 = 563;
	const int 武将_吴国太 = 198;
	*/
	// ===========================================


	class Main
	{

		pk::building@ building_;
		pk::building@ kunshu_building;
		pk::force@ force_;
		pk::person@ kunshu_;
		pk::person@ gunshi_;
		pk::person@ foster_son;
		pk::person@ support;
		pk::city@ kunshu_city;
		pk::city@ city_;
		string kunshu_name;
		string foster_son_name;
		pk::list<pk::person@> person_list;
		array<pk::person@> person_sel_arr;

		Main()
		{
			//养子
			pk::menu_item item;
			item.menu = individual_menu::菜单_个人;
																				 
			item.shortcut = "3";
			item.init = pk::building_menu_item_init_t(init);
			item.is_visible = pk::menu_item_is_visible_t(isVisible);
			item.is_enabled = pk::menu_item_is_enabled_t(isEnabled);
			item.get_text = pk::menu_item_get_text_t(getText);
			item.get_desc = pk::menu_item_get_desc_t(getDesc);
			item.handler = pk::menu_item_handler_t(handler);
			pk::add_menu_item(item);
			//宗室
			pk::menu_item item_宗室;
			item_宗室.menu = individual_menu::菜单_个人;
			item_宗室.init = pk::building_menu_item_init_t(init);
			item_宗室.is_visible = pk::menu_item_is_visible_t(isVisible_宗室);
			item_宗室.is_enabled = pk::menu_item_is_enabled_t(isEnabled_宗室);
			item_宗室.get_text = pk::menu_item_get_text_t(getText_宗室);
			item_宗室.get_desc = pk::menu_item_get_desc_t(getDesc_宗室);
			item_宗室.handler = pk::menu_item_handler_t(handler_宗室);
			pk::add_menu_item(item_宗室);
		}

		void init(pk::building@ building)
		{
			@building_ = @building;
			@force_ = pk::get_force(building.get_force_id());
			@kunshu_ = pk::get_person(pk::get_kunshu_id(building));
			@gunshi_ = pk::get_person(force_.gunshi);
			if (!pk::is_alive(gunshi_))//军师空缺
			{
				@gunshi_ = pk::get_person(무장_문관);
				//force_.gunshi = 715;  //暂定军师
				//force_.update();
			}
			@kunshu_building = pk::get_building(kunshu_.service);
			@kunshu_city = pk::building_to_city(kunshu_building);
			@city_ = pk::building_to_city(building);

			@support = pk::is_alive(gunshi_) ? gunshi_ : pk::get_person(무장_문관);
		}
		//养子
		//义子的数量
		int Yiznum(pk::person@ kunshu_)
		{
			int num = 0;  //初始化
			pk::list<pk::person@> list_s = pk::get_person_list(pk::mibun_flags(身份_君主, 身份_都督, 身份_太守, 身份_一般, 身份_在野, 身份_俘虏));
			for (int l = 0; l < list_s.count; l++)
			{
				pk::person@ person_yizi = list_s[l];
				if (person_yizi.father == kunshu_.get_id() && person_yizi.ketsuen != kunshu_.ketsuen)  num += 1; //区分义子和养子
			}
			return num;
		}
		//养子数量
		int Yaznum(pk::person@ kunshu_)
		{
			int num = 0;  //初始化
			pk::list<pk::person@> list_s = pk::get_person_list(pk::mibun_flags(身份_君主, 身份_都督, 身份_太守, 身份_一般, 身份_在野, 身份_俘虏));
			for (int l = 0; l < list_s.count; l++)
			{
				pk::person@ person_yizi = list_s[l];
				if (person_yizi.father == kunshu_.get_id() && person_yizi.ketsuen == kunshu_.ketsuen)  num += 1; //区分义子和养子
			}
			return num;
		}
		//子女数量
		int Zinvnum(pk::person@ kunshu_)
		{
			int num = 0;  //初始化
			pk::list<pk::person@> list_s = pk::get_person_list(pk::mibun_flags(身份_君主, 身份_都督, 身份_太守, 身份_一般, 身份_在野, 身份_俘虏));
			for (int l = 0; l < list_s.count; l++)
			{
				pk::person@ person_yizi = list_s[l];
				if (person_yizi.father == kunshu_.get_id())  num += 1; //不区分义子和养子
			}
			return num;
		}
		bool isVisible()
		{
			if (kunshu_.service != building_.get_id()) return false;
			else if (Yaznum(@ kunshu_)>5) return false;
			else if (Yiznum(@ kunshu_)>5) return false;
			return true;
		}

		bool isEnabled()
		{
			if (building_.get_id() != kunshu_.service) return false;
			else if (pk::is_absent(kunshu_) or pk::is_unitize(kunshu_) or kunshu_.action_done) return false;
			else if (force_.tp < TP_COST) return false;
			else if (pk::get_district(pk::get_district_id(force_, 1)).ap < ACTION_COST) return false;
			return true;
		}

		string getText()
		{
			return pk::encode("收养义子");
		}

		string getDesc()
		{
			if (building_.get_id() != kunshu_.service)
				return pk::encode("只能在君主所在城市或港关实行.");
			else if (pk::is_absent(kunshu_) or pk::is_unitize(kunshu_) or kunshu_.action_done)
				return pk::encode("君主已行动或不在城市中.");
			else if (force_.tp < TP_COST)
				return pk::encode(pk::format("技巧P不足.(技巧P {})", TP_COST));
			else if (pk::get_district(pk::get_district_id(force_, 1)).ap < ACTION_COST)
				return pk::encode(pk::format("行动力不足 (必须 {} 行动力)", ACTION_COST));
			else
				return pk::encode(pk::format("收养义子. (行动力 {})", ACTION_COST));
		}

		bool handler()
		{

			if (pk::choose({ pk::encode("  是  "), pk::encode("  否  ") }, pk::encode(pk::format("要收养子女吗?\n(技巧P {} )", TP_COST)), kunshu_) == 1)
				return false;


			bool person_confirm = false;

			person_list = getTargetList();

			while (!person_confirm)
			{
				// 무장 선택 창을 열어서 선택하기
				person_sel_arr = pk::list_to_array(pk::person_selector(pk::encode("武将选择"), pk::encode("请选择做为子女的武将."), person_list, 1, 1));

				// 무장 선택
				@foster_son = person_sel_arr[0];

				// 선택 취소 시 종료
				if (!pk::is_alive(foster_son)) return false;

				// 선택된 무장의 이름
				foster_son_name = pk::decode(pk::get_name(foster_son));

				person_confirm = pk::yes_no(pk::encode(pk::format("收养\x1b[1x{}\x1b[0x做为子女吗?", foster_son_name)));
			}
			//剧情
				   
														   

				   
																	 

				   
								 
									  
									  
									  

					   

			pk::scene(pk::scene_t(scene_Event));
			//剧情结束
			if (force_.gunshi == 715)
			{
				force_.gunshi = -1;  //回收军师
				force_.update();
			}
			// 행동력 감소.
			auto district = pk::get_district(pk::get_district_id(force_, 1));
			pk::add_ap(district, -ACTION_COST);

			// 기교P 감소
			ch::add_tp(force_, -TP_COST, force_.get_pos());

			kunshu_.action_done = true;

			return true;

		}

		void scene_Event()
		{
			if (foster_son.get_id() == gunshi_.get_id()) @support = pk::get_person(무장_문관);

			pk::event::diplomacy(kunshu_, support, foster_son, pk::event::diplomacy_t(scene_Event_1));
			pk::move_screen(kunshu_city.get_pos(), 2000);
		}

		void scene_Event_1()
		{
			string call_kunshu = "主公";
			switch (force_.title)
			{
			case 0: call_kunshu = "陛下"; break;
			case 1: call_kunshu = "王上"; break;
			default:  call_kunshu = "主公"; break;
			}
			string self_kunshu = "我";
			switch (force_.title)
			{
			case 0: self_kunshu = "朕"; break;
			case 1: self_kunshu = "孤王"; break;
			default:  self_kunshu = "我"; break;
			}
			string self_foster_son = "我";
			if (foster_son.base_stat[1] >= 75)
			{
				self_foster_son = "末将";
			}
			else if (foster_son.base_stat[2] >= 75 and force_.title == 0)
			{
				self_foster_son = "微臣";
			}
			else
			{
			}
			pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x,您传唤\x1b[1x{}\x1b[0x?", call_kunshu, self_foster_son)), foster_son);
			pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x,你来了?", foster_son_name)), kunshu_);

			if (foster_son.sex == 성별_남)
				pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x叫你过来是想收你为子.", self_kunshu)), kunshu_);
			else if (foster_son.sex == 성별_여)
				pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x叫你过来是想收你为女.", self_kunshu)), kunshu_);
			//能力判断
			pk::trace(pk::format("野心 ：{}", foster_son.ambition));

			if (Zinvnum(@ kunshu_) == 0 && foster_son.giri == 义理_低)
			{
				foster_son_name = pk::decode(pk::get_name(foster_son));
				kunshu_name = pk::decode(pk::get_name(kunshu_));
				pk::message_box(pk::encode("你也配...看招！"), foster_son);
				if(foster_son.base_stat[武将能力_武力] - kunshu_.base_stat[武将能力_武力] >30)
				{
					//突袭成功
					pk::message_box(pk::encode("哈哈哈，何人不服！暂且饶你狗命。"), foster_son);
					force_.kunshu = foster_son.get_id();
					force_.update();
					kunshu_.mibun = 身份_一般;
					kunshu_.rank=80;//兼容汉官
					kunshu_.shoubyou =伤病_重症;
					kunshu_.update();
			 		foster_son.mibun = 身份_君主;
			 		foster_son.rank=80;//兼容汉官
			 		foster_son.update();
					pk::message_box(pk::encode(pk::format("{}}突袭主公{}，成功篡夺君位。",foster_son_name,kunshu_name)));					
				}
				else
				{
					//突袭失败
					pk::message_box(pk::encode("天不助我！溜之大吉！"), foster_son);
					pk::resign(foster_son);
					pk::message_box(pk::encode(pk::format("{}}突袭主公{}，失败逃脱下野。",foster_son_name,kunshu_name)));	
				}
			}
			else //正常收养
			{
				pk::message_box(pk::encode(pk::format("对{}这样卑微的人来说,\n这简直和做梦一样...", self_foster_son)), foster_son);
				pk::message_box(pk::encode(pk::format("以后我也会将{}当作亲生父母一样侍奉.", call_kunshu)), foster_son);
				pk::message_box(pk::encode("非常好."), kunshu_);

				if (foster_son.sex == 성별_남)
				{
					pk::message_box(pk::encode(pk::format("现在开始你就是{}的儿子了.", self_kunshu)), kunshu_);
					pk::message_box(pk::encode(pk::format("恭喜\x1b[1x{}\x1b[0x收\x1b[1x{}\x1b[0x为子.", call_kunshu, foster_son_name)), support);
				}
				else if (foster_son.sex == 성별_여)
				{
					pk::message_box(pk::encode(pk::format("现在开始你就是{}的女儿了.", self_kunshu)), kunshu_);
					pk::message_box(pk::encode(pk::format("恭喜\x1b[1x{}\x1b[0x收\x1b[1x{}\x1b[0x为女.", call_kunshu, foster_son_name)), support);
				}
				//汉室宗亲被收养时会失去宗籍
				if(foster_son.ketsuen == 700 )
						 
				{
					foster_son.ketsuen = foster_son.get_id();
					foster_son.generation = 1;
				}
				//赐姓名，汉室血统不能收养
				if (force_.title <= 2 and kunshu_.ketsuen != 700)
				{
					bool	confirm = pk::yes_no(pk::encode("是否给新子女赐\x1b[1x姓\x1b[0x?"));
					if (confirm == true)
					{
						foster_son.ketsuen = kunshu_.ketsuen;
						foster_son.generation = kunshu_.generation + 1;
						foster_son.azana_read = foster_son.sei + foster_son.mei;
						if(kunshu_.sei == pk::encode("祝") and kunshu_.mei  == pk::encode("融") and kunshu_.get_id() == 武将_祝融)
						{
							foster_son.sei = pk::encode("祝融");
						}
						else if(kunshu_.sei == pk::encode("带来") and kunshu_.get_id() == 武将_带来洞主)
						{
							foster_son.sei = pk::encode("祝融");
						}
						else if(kunshu_.sei == pk::encode("花") and kunshu_.mei  == pk::encode("鬘") and kunshu_.get_id() == 武将_花鬘)
						{
							foster_son.sei = pk::encode("祝融");
						}
						else if(kunshu_.sei == pk::encode("大") and kunshu_.mei  == pk::encode("乔") and kunshu_.get_id() == 武将_大乔)
						{
						foster_son.sei = pk::encode("桥");
						}
						else if(kunshu_.sei == pk::encode("小") and kunshu_.mei  == pk::encode("乔") and kunshu_.get_id() == 武将_小乔)
						{
							foster_son.sei = pk::encode("桥");
						}
						else if(kunshu_.sei == pk::encode("貂") and kunshu_.get_id() == 武将_貂蝉 )
						{
						foster_son.sei = pk::encode("王");
						}
						else foster_son.sei = kunshu_.sei;
						if(foster_son.mei  == pk::encode("乔") and foster_son.get_id() == 武将_小乔)
						{
							foster_son.mei = pk::get_person(pk::rand(670)).mei+pk::encode("姬");
						}
						else if(foster_son.mei  == pk::encode("乔") and foster_son.get_id() == 武将_大乔)
						{
							foster_son.mei = pk::get_person(pk::rand(670)).mei+pk::encode("姬");
						}
						else if(foster_son.get_id() == 武将_吴国太)
						{
							foster_son.mei = pk::get_person(pk::rand(670)).mei+pk::encode("君");
						}
						else if(foster_son.mei ==pk::encode("氏"))
						{
							foster_son.mei = pk::get_person(pk::rand(670)).mei+pk::encode("女");
						}
						else if(foster_son.mei ==pk::encode("洞主") or foster_son.mei ==pk::encode("大王"))
						{
							foster_son.mei = pk::get_person(pk::rand(670)).mei;
						}
						else
						{
							bool confirm_t = pk::yes_no(pk::encode("是否给新子女赐\x1b[1x名\x1b[0x?"));
							if (confirm_t == true) foster_son.mei = pk::get_person(pk::rand(670)).mei;
						}
						foster_son.update();
						string foster_son_name_new = pk::decode(pk::get_name(foster_son));
						pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x被赐名为\x1b[1x{}\x1b[0x.", foster_son_name, foster_son_name_new)));
						switch (pk::rand(2))
						{
							case 0: pk::message_box(pk::encode("谢主公赐姓，某为主公赴汤蹈火！"), foster_son); break;
							case 1: pk::message_box(pk::encode(pk::format("谢{}赐姓名!", call_kunshu)), foster_son); break;
						}

					}
				}
				//结尾
				foster_son_name = pk::decode(pk::get_name(foster_son));
				if (kunshu_.sex == 성별_남)
					foster_son.father = force_.kunshu;
				else if (kunshu_.sex == 성별_여)
					foster_son.mother = force_.kunshu;
				foster_son.update();
				if(foster_son.ketsuen == kunshu_.ketsuen)
				{
					if (foster_son.sex == 성별_남)
						pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x成为了养子.", foster_son_name)));
					else if (foster_son.sex == 성별_여)
						pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x成为了养女.", foster_son_name)));
				}	
				else
				{
					if (foster_son.sex == 성별_남)
						pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x成为了义子.", foster_son_name)));
					else if (foster_son.sex == 성별_여)
						pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x成为了义女.", foster_son_name)));
				}
			}
		}
		pk::list<pk::person@> getTargetList()
		{
			pk::list<pk::person@> list;
			int force_id = force_.get_id();
			int kunshu_0 = kunshu_.get_id();
			auto person_list = pk::list_to_array(pk::get_person_list(force_, pk::mibun_flags(身份_都督, 身份_太守, 身份_一般)));
			for (int i = 0; i < int(person_list.length); i++)
			{
				pk::person@ person = person_list[i];
				if (pk::is_alive(person))
				{
					if (!pk::is_absent(person) and !pk::is_unitize(person)
							and (person.birth > kunshu_.birth)//年龄
							and !pk::is_fuufu(person, kunshu_0)//夫妇
							and !pk::is_gikyoudai(person, kunshu_0)//义兄弟
							and !pk::is_oyako(person, kunshu_0)//亲子							
							and !(pk::is_ketsuen(person, kunshu_0) and person.generation<= kunshu_.generation)//血缘长辈
							and !pk::is_dislike(person, kunshu_0))//讨厌
							list.add(person);
				}
			}
			return list;
		}
		pk::list<pk::person@> getTargetList_宗室()
		{
			pk::list<pk::person@> list;
			int force_id = force_.get_id();
			int kunshu_0 = kunshu_.get_id();
			auto person_list = pk::list_to_array(pk::get_person_list(force_, pk::mibun_flags(身份_都督, 身份_太守, 身份_一般)));
			for (int i = 0; i < int(person_list.length); i++)
			{
				pk::person@ person = person_list[i];
				if (pk::is_alive(person))
				{
					if (!pk::is_absent(person) and !pk::is_unitize(person)
																		   
										  
											  
							and !pk::is_ketsuen(person, kunshu_0)
							and !pk::is_dislike(person, kunshu_0))
							list.add(person);
				}
			}
	
			return list;
		}
		//宗室
		bool isVisible_宗室()
		{
			if (kunshu_.service != building_.get_id()) return false;
			if(force_.title>1) return false;//帝王可以收宗室
			if(kunshu_.ketsuen == 700) return false;//汉室不能收宗室
			return true;
		}

		bool isEnabled_宗室()
		{
			if (building_.get_id() != kunshu_.service) return false;
			else if (pk::is_absent(kunshu_) or pk::is_unitize(kunshu_) or kunshu_.action_done) return false;
			else if (force_.tp < TP_COST) return false;
			else if (pk::get_district(pk::get_district_id(force_, 1)).ap < ACTION_COST) return false;
			return true;
		}

		string getText_宗室()
		{
			return pk::encode("收纳宗室");
		}

		string getDesc_宗室()
		{
			if (building_.get_id() != kunshu_.service)
				return pk::encode("只能在君主所在城市或港关实行.");
			else if (pk::is_absent(kunshu_) or pk::is_unitize(kunshu_) or kunshu_.action_done)
				return pk::encode("君主已行动或不在城市中.");
			else if (force_.tp < TP_COST)
				return pk::encode(pk::format("技巧P不足.(技巧P {})", TP_COST));
			else if (pk::get_district(pk::get_district_id(force_, 1)).ap < ACTION_COST)
				return pk::encode(pk::format("行动力不足 (必须 {} 行动力)", ACTION_COST));
			else
				return pk::encode(pk::format("收纳宗室. (行动力 {})", ACTION_COST));
		}
		bool handler_宗室()
		{

			if (pk::choose({ pk::encode("  是  "), pk::encode("  否  ") }, pk::encode(pk::format("要收纳宗室吗?\n(技巧P {} )", TP_COST)), kunshu_) == 1)
				return false;


			bool person_confirm = false;

			person_list = getTargetList_宗室();

			while (!person_confirm)
			{
				// 무장 선택 창을 열어서 선택하기
				person_sel_arr = pk::list_to_array(pk::person_selector(pk::encode("武将选择"), pk::encode("请选择做为宗室的武将."), person_list, 1, 1));

				// 무장 선택
				@foster_son = person_sel_arr[0];

				// 선택 취소 시 종료
				if (!pk::is_alive(foster_son)) return false;

				// 선택된 무장의 이름
				foster_son_name = pk::decode(pk::get_name(foster_son));

				person_confirm = pk::yes_no(pk::encode(pk::format("收纳\x1b[1x{}\x1b[0x做为宗室吗?", foster_son_name)));
			}
			// 收为宗室
			pk::scene(pk::scene_t(scene_Event_宗室));
			foster_son.ketsuen = kunshu_.ketsuen;
			foster_son.azana_read = foster_son.sei + foster_son.mei;
			if(kunshu_.sei == pk::encode("祝") and kunshu_.mei  == pk::encode("融") and kunshu_.get_id() == 武将_祝融)
			{
				foster_son.sei = pk::encode("祝融");
			}
			else if(kunshu_.sei == pk::encode("带来") and kunshu_.get_id() == 武将_带来洞主)
			{
				foster_son.sei = pk::encode("祝融");
			}
			else if(kunshu_.sei == pk::encode("花") and kunshu_.mei  == pk::encode("鬘") and kunshu_.get_id() == 武将_花鬘)
			{
				foster_son.sei = pk::encode("祝融");
			}
			else if(kunshu_.sei == pk::encode("大") and kunshu_.mei  == pk::encode("乔") and kunshu_.get_id() == 武将_大乔)
			{
				foster_son.sei = pk::encode("桥");
			}
			else if(kunshu_.sei == pk::encode("小") and kunshu_.mei  == pk::encode("乔") and kunshu_.get_id() == 武将_小乔)
			{
				foster_son.sei = pk::encode("桥");
			}
			else if(kunshu_.sei == pk::encode("貂") and kunshu_.get_id() == 武将_貂蝉 )
			{
				foster_son.sei = pk::encode("王");
			}
			else
			{
				foster_son.sei = kunshu_.sei;
			}
			if(foster_son.mei  == pk::encode("乔") and foster_son.get_id() == 武将_小乔)
			{
					foster_son.mei = pk::get_person(pk::rand(670)).mei+pk::encode("姬");
			}
			else if(foster_son.mei  == pk::encode("乔") and foster_son.get_id() == 武将_大乔)
			{
				foster_son.mei = pk::get_person(pk::rand(670)).mei+pk::encode("姬");
			}
			else if(foster_son.get_id() == 武将_吴国太)
			{
				foster_son.mei = pk::get_person(pk::rand(670)).mei+pk::encode("君");
			}
			else if(foster_son.mei ==pk::encode("氏"))
			{
				foster_son.mei = pk::get_person(pk::rand(670)).mei+pk::encode("女");
			}
			else if(foster_son.mei ==pk::encode("洞主") or foster_son.mei ==pk::encode("大王"))
			{
				foster_son.mei = pk::get_person(pk::rand(670)).mei;
			}
			foster_son.update();
			pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x成为了宗室.", foster_son_name)));
			
			//if (force_.gunshi == 715)//军师回收
			//{
			//	force_.gunshi = -1;  //回收军师
			//	force_.update();
			//}
			// 행동력 감소.
			auto district = pk::get_district(pk::get_district_id(force_, 1));
			pk::add_ap(district, -ACTION_COST);

			// 기교P 감소
			ch::add_tp(force_, -TP_COST, force_.get_pos());

			kunshu_.action_done = true;

			return true;

		}
		void scene_Event_宗室()
		{
			if (foster_son.get_id() == gunshi_.get_id()) @support = pk::get_person(무장_문관);

			pk::event::diplomacy(kunshu_, support, foster_son, pk::event::diplomacy_t(scene_Event_1_宗室));
			pk::move_screen(kunshu_city.get_pos(), 2000);
		}

		void scene_Event_1_宗室()
		{
			string call_kunshu = "主公";
			switch (force_.title)
			{
			case 0: call_kunshu = "陛下"; break;
			case 1: call_kunshu = "王上"; break;
			default:  call_kunshu = "主公"; break;
			}
			string self_kunshu = "我";
			switch (force_.title)
			{
			case 0: self_kunshu = "朕"; break;
			case 1: self_kunshu = "孤王"; break;
			default:  self_kunshu = "我"; break;
			}
			string self_foster_son = "我";
			if (foster_son.base_stat[1] >= 75)
			{
				self_foster_son = "末将";
			}
			else if (foster_son.base_stat[2] >= 75 and force_.title == 0)
			{
				self_foster_son = "微臣";
			}
			else
			{
			}
			//世代处理
			string 辈分="族";
			if(kunshu_.generation == 0 or kunshu_.generation == 1)
			{
				if(foster_son.birth - kunshu_.birth >15 or foster_son.father == kunshu_.get_id() or foster_son.mother == kunshu_.get_id())
				{
					foster_son.generation = kunshu_.generation + 1;
					辈分=辈分+"子";
				}
				else 
				{
					foster_son.generation = kunshu_.generation;
					if(kunshu_.birth < foster_son.birth)
					{	
						辈分=辈分+"弟";
					}
					else 辈分=辈分+"兄";
				}
			}
			else
			{
				if(foster_son.birth - kunshu_.birth >15 or foster_son.father == kunshu_.get_id() or foster_son.mother == kunshu_.get_id())
				{
					foster_son.generation = kunshu_.generation + 1;
					辈分=辈分+"子";
				}
				else if(kunshu_.birth - foster_son.birth >15)
				{
					foster_son.generation = kunshu_.generation - 1;
					辈分=辈分+"叔";
				}
				else
				{
					foster_son.generation = kunshu_.generation;
					if(kunshu_.birth < foster_son.birth)
					{	
						辈分=辈分+"弟";
					}
					else 辈分=辈分+"兄";
				}
			}
			foster_son.update();
			pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x,您传唤\x1b[1x{}\x1b[0x?", call_kunshu, self_foster_son)), foster_son);
			pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x,你来了?", foster_son_name)), kunshu_);
			pk::message_box(pk::encode(pk::format("\x1b[1x{}\x1b[0x叫你过来是想收你为{}.", self_kunshu,辈分)), kunshu_);
			pk::message_box(pk::encode(pk::format("对{}这样卑微的人来说,\n这简直和做梦一样...", self_foster_son)), foster_son);
			pk::message_box(pk::encode(pk::format("以后我也会将不负{}的期望.", call_kunshu)), foster_son);
			pk::message_box(pk::encode("非常好."), kunshu_);
		}
	}
	Main main;
}